<!--
 * @Author: krsea 965837746@qq.com
 * @Date: 2025-03-02 15:55:43
 * @LastEditors: krsea 965837746@qq.com
 * @LastEditTime: 2025-03-02 15:55:50
 * @FilePath: \2306\week2\test.html
 * @Description: 
 * 
 * Copyright (c) 2025 by ${git_name_email}, All Rights Reserved. 
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>局部组件</title>
    <!-- 引入vue.js -->
    <script src="../js/vue.js"></script>
</head>
<body>
    <!-- 挂载点 -->
    <div id="app">
        <my-component></my-component>
        <my-component></my-component>
        <my-component></my-component>
        <my-component></my-component>
    </div>
    <!-- 定义模板 -->
    <template id="temp1">
        <div>
            <p>我是色板1</p>
            <input type="color"/>
        </div>
    </template>
    <template id="temp2">
        <div>
            <p>我是色板2</p>
            <input type="color"/>
        </div>
    </template>
    <template id="temp">
        <component-a></component-a>
        <component-b></component-b>
    </template>
    <!-- 使用javascript 脚本 -->
    <script type="text/javascript">
        // 定义子组件
        var Child1 = {
            template: '#temp1'
        };
        var Child2 = {
            template: '#temp2'
        };
        // 定义 myComponent 组件
        var myComponent = {
            template: '#temp',
            components: {
                'component-a': Child1,
                'component-b': Child2
            }
        };
        // 创建 Vue 实例
        var app = new Vue({
            el: '#app',
            components: {
                'my-component': myComponent
            }
        });
    </script>
</body>
</html>
